<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登记历史</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.19.1/dist/bootstrap-table.css">
    <link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.19.1/dist/bootstrap-table.min.css">
</head>
<body>
<div>
    <table id="bootstrap-table">
        <thead>
        <tr>
            <th data-field="healthState">健康状况</th>
            <th data-field="temperature">体温</th>
            <th data-field="isOut" data-formatter="fm_state">是否外出</th>
            <th data-field="time" data-formatter="fm_time">填报时间</th>
            <th data-field="workState">工作状态</th>
            <th data-field="memo">备注</th>
        </tr>
        </thead>
    </table>
</div>
</body>
<div th:replace="common :: common"></div>
<!-- Latest compiled and minified JavaScript -->
<script src="https://unpkg.com/bootstrap-table@1.19.1/dist/bootstrap-table.min.js"></script>
<!-- Latest compiled and minified Locales -->
<script src="https://unpkg.com/bootstrap-table@1.19.1/dist/locale/bootstrap-table-zh-CN.min.js"></script>
</html>
<script>
    $(function () {
        $('#bootstrap-table').bootstrapTable({
            url: "/viewHistory",                                   // 请求后台的URL（*）
            method: 'post',
            sidePagination: "client",
            pagination: true,                                   // 是否显示分页（*）
            pageNumber: 1,                                      // 初始化加载第一页，默认第一页
            pageSize: 5,                                        // 每页的记录行数（*）
            pageList: [5, 10],                         // 可供选择的每页的行数（*）
            showRefresh: true,
        });
    })

    function fm_state(value, row, index) {
        return value == true ? '是' : '否';
    }

    function fm_time(value, row, index) {
        return timeFmt(value);
    }

    function timeFmt(value) {
        var date=new Date(value);
        var year=date.getFullYear();
        var month=date.getMonth()+1;
        month=month>9?month:('0'+month);
        var day=date.getDate();
        day=day>9?day:('0'+day);
        var hh=date.getHours();
        hh=hh>9?hh:('0'+hh);
        var mm=date.getMinutes();
        mm=mm>9?mm:('0'+mm);
        var ss=date.getSeconds();
        ss=ss>9?ss:('0'+ss);
        var time=year+'-'+month+'-'+day+' '+hh+':'+mm+':'+ss;
        return time;
    }
</script>